import Vue from 'vue'
import axios from 'axios'

export var bus = new Vue({
  methods: {
    execute (request) {
      this.$emit('executeNewReq', request)
      return axios.request({
        method: request.method === 'GET' && request.data ? 'POST' : request.method,
        url: request.url,
        data: request.data
      }).then((res) => {
        this.$emit('executeNewRes', res)
        return res
      })
    }
  }
})

// bus.$on('id-selected', function (id) {
//   alert(id)
// })
